package fr.mma.livraison.dao;

import com.googlecode.objectify.ObjectifyService;

import fr.mma.livraison.model.persistence.Admin;
import fr.mma.socle.dao.CommonDao;

public class AdminDao extends CommonDao<Admin> {

	public AdminDao() {
		super(Admin.class);
	}

	static {
		ObjectifyService.register(Admin.class);
	}

	public Admin getOrCreate(final long identifiant) {
		Admin found = ofy().find(Admin.class, identifiant);
		if (found == null) {
			found = new Admin(identifiant);
		}
		return found;
	}

	public boolean isAdmin(final String name) {
		return ofy().query(Admin.class).filter("name", name).count() > 0;
	}

	public void save(final Admin admin) {
		ofy().put(admin);
	}

}
